import requests
from config import url, headers_web


class AiStatistics:
    def __init__(self):
        self.url = url
        self.headers_web = headers_web

    @classmethod
    def post_stu_attendance_detail(cls, url: str, headers=headers_web, params=None, body=None):
        """
        @Summary: 学生签到率统计页面：获取学生到课率统计详情数据
        @Description: 管理端-数据统计报表-学生到课率检测
        :param url: "http://192.168.1.32:8080"
        :param headers: {
                        "Content-Type": "application/json",
                        "X-Requested-With": "XMLHttpRequest",
                        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)
                        AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
                       }
        :param params:{
                        courseTableId: "string",  #课表ID
                        date : "string",  #日期
                        segment : "string",  #上课节次
                        validCode : "string"  #验证码&signKey=123123(md5加密)
                        }
        :param body:{
                      "beginTime": "string", #上课开始时间
                      "collegeId": "string", #学院Id
                      "endTime": "string", #上课结束时间
                      "maxAttendanceRate": integer,  #最大到课率
                      "minAttendanceRate": integer, #最小到课率
                      "page": integer, #当前页
                      "pageSize": integer, #每页数量
                      "roomName": "string", #教室名称
                      "roomType": "string" #教室类型
                    }
        :return:[
                          {
                            "attendanceRate": number, #到课率
                            "expectedAttendance": integer, #应到人数
                            "recognitionTime": "string", #识别时间
                            "spotNum": integer, #识别人数
                            "spotNumFilePath": "string", #点人数文件路径
                            "spotNumInnerIp": "string", #点人数内网Ip
                            "spotNumOuterIp": "string" #点人数外网Ip
                          }
                        ]
        """
        url_path = url + f"/teachingApi/v1/aistatistics/getstudentattendancedetail"
        r = requests.post(url=url_path, headers=headers, params=params, json=body)
        return r

    @classmethod
    def post_get_stu_attendance_statistics(cls, url: str, headers=headers_web, params=None, body=None):
        """
        @Summary: 学生签到率统计页面：获取学生到课率统计数据
        @Description: 管理端-数据统计报表-学生到课率检测
        :param url: "http://192.168.1.32:8080"
        :param headers: {
                        "Content-Type": "application/json",
                        "X-Requested-With": "XMLHttpRequest",
                        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)
                        AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
                       }
        :param params:{validCode : "string"  #验证码&signKey=123123(md5加密)}
        :param body:{}
        :return:{
        "page": integer,  # 当前页
        "pageSize": integer,  # 每页数量
        "studentAttendanceVos":[{
                                "activityAttendancePer": "string",  # 学生活动签到率
                                "courseName": "string",  # 课程名称
                                "courseTableDetailId": "string",  # 课表明细Id
                                "groupName": "string",  # 班级名称
                                "roomId": "string",  # 教室id
                                "roomName": "string",  # 授课地点（教室）
                                "segments": "string",  # 大节次信息
                                "studentAttendancePer": "string",  # 学生到课率
                                "taskEndTime": "string",  # 点人数任务结束时间
                                "teacherInfo": "string",  # 教师姓名+工号
                                "teacherNo": "string"  # 教师工号
                            }],
        "total": integer,  # 总条数
        "totalPage": integer  # 总页数
                }
        """
        url_path = url + f"/teachingApi/v1/aistatistics/getstudentattendancestatistics"
        r = requests.post(url=url_path, headers=headers, params=params, json=body)
        return r
